<?php

namespace Morrow;

class PageController extends DefaultController {
	public function run() {
		         
        if($this->session->get("email")){
         	$string= "
         		
         				<li><a href='user'><i class='icon-th-list'></i> 主页</a></li>
         				<li><a href='logout'><i class='icon-off'></i> 登出</a></li>
         			
         		";
         		$button = "<a class='btn btn-large btn-success' href='user'>我的主页</a>";
         	
        }
        else{
        	$string ="
                        <li><a href='webapp/about'>关于</a></li>
                        <li><a href='webapp/contact'>联系</a></li>
        		<li><a href='login'>登陆</a></li>
         		<li><a href='register'>注册</a></li>";
         		$button = "<a class='btn btn-large btn-success' href='register'>现在就加入我们</a>";
        }



        @$messenger=$this->session->get("messenger");

        if($messenger){

                $dollar="$";
                $messenger_content ="not difine";

                $messenger_jq="<script>".$dollar."('#messenger').fadeIn('slow');</script>";

                if($messenger=="logout1"){
                        $messenger_content="登出成功！";
                }

                if($messenger=="register1"){
                        $messenger_content="注册成功！";
                }

                if($messenger=="emailsend1"){
                        $messenger_content="修改密码链接已发到邮箱！";
                }

                if($messenger=="changepassword1"){
                        $messenger_content="修改密码成功！";
                }

                $messenger_array=array('jq' => $messenger_jq, 'content' => $messenger_content );


        }
        else{
                $messenger_array=array('jq' => 'no_jq', 'content' => 'no_content' );
        }

        $this->view->setContent($messenger_array, 'messenger');
        $this->view->setContent($string, 'data');
        $this->view->setContent($button, 'button');

        $this->session->delete('messenger');
	}
}
